﻿using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RunWrapper = Microsoft.SqlServer.Dts.Runtime.Wrapper;
using DatabaseGroup.SSIS.SourceAdapters.View;
using DatabaseGroup.SSIS.SourceAdapters;
using DatabaseGroup.SSIS.SourceAdapters.Presenter;

namespace DatabaseGroup.IntegrationTests.SSIS.SourceAdapters
{
    [TestClass]
    public class StandardOutputBasicTest
    {
        private TestContext _testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return _testContextInstance;
            }
            set
            {
                _testContextInstance = value;
            }
        }

        [TestMethod]
        public void StdOut_ASCII1ColNoTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_ASCII_1Col_NoTQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_ASCII_1Col_NoTQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_ASCII1ColTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_ASCII_1Col_TQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.GeneralSettings.TextQualifier = "\"";

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_ASCII_1Col_TQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_ASCII1ColTQHeadersCustomDelInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_ASCII_1Col_TQ_Headers_CustomDel.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.GeneralSettings.TextQualifier = "\'";
            dfs.GeneralSettings.HeaderRowsToSkip = 10;
            dfs.GeneralSettings.HeaderRowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");
            dfs.ColumnSettings.ColumnDelimiter = DelimiterStringConverter.ToReadableDelim("|");
            dfs.ColumnSettings.RowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_ASCII_1Col_TQ_Headers_CustomDel.txt", 10, "\n"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_ASCII10ColNoTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_ASCII_10Col_NoTQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol2", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol3", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol4", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol5", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol6", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol7", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol8", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol9", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol10", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_ASCII_10Col_NoTQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_ASCII10ColTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_ASCII_10Col_TQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol2", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol3", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol4", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol5", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol6", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol7", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol8", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol9", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol10", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.GeneralSettings.TextQualifier = "\"";

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_ASCII_10Col_TQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_ASCII10ColTQHeadersCustomDelInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_ASCII_10Col_TQ_Headers_CustomDel.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol2", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol3", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol4", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol5", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol6", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol7", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol8", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol9", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol10", 0, 0, RunWrapper.DataType.DT_STR, 255, 1252));
            dfs.GeneralSettings.TextQualifier = "\'";
            dfs.GeneralSettings.HeaderRowsToSkip = 10;
            dfs.GeneralSettings.HeaderRowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");
            dfs.ColumnSettings.ColumnDelimiter = DelimiterStringConverter.ToReadableDelim("|");
            dfs.ColumnSettings.RowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_ASCII_10Col_TQ_Headers_CustomDel.txt", 10, "\n"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_UTF81ColNoTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_UTF8_1Col_NoTQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.CodePage = PresenterUtils.ConvertCodepageToString(65001);

            //dfs.SavePackageToFile(@"C:\SSIS_TestProject\Integration Services Project1\Integration Services Project1\intdfs.dtsx");
            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_UTF8_1Col_NoTQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_UTF81ColTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_UTF8_1Col_TQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.TextQualifier = "\"";
            dfs.GeneralSettings.CodePage = PresenterUtils.ConvertCodepageToString(65001);

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_UTF8_1Col_TQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_UTF81ColTQHeadersCustomDelInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_UTF8_1Col_TQ_Headers_CustomDel.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.TextQualifier = "\'";
            dfs.GeneralSettings.HeaderRowsToSkip = 10;
            dfs.GeneralSettings.HeaderRowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");
            dfs.ColumnSettings.ColumnDelimiter = DelimiterStringConverter.ToReadableDelim("|");
            dfs.ColumnSettings.RowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");
            dfs.GeneralSettings.CodePage = PresenterUtils.ConvertCodepageToString(65001);

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_UTF8_1Col_TQ_Headers_CustomDel.txt", 10, "\n"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_UTF810ColNoTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_UTF8_10Col_NoTQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol2", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol3", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol4", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol5", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol6", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol7", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol8", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol9", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol10", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.CodePage = PresenterUtils.ConvertCodepageToString(65001);

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_UTF8_10Col_NoTQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_UTF810ColTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_UTF8_10Col_TQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol2", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol3", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol4", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol5", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol6", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol7", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol8", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol9", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol10", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.TextQualifier = "\"";
            dfs.GeneralSettings.CodePage = PresenterUtils.ConvertCodepageToString(65001);

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_UTF8_10Col_TQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_UTF810ColTQHeadersCustomDelInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_UTF8_10Col_TQ_Headers_CustomDel.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol2", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol3", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol4", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol5", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol6", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol7", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol8", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol9", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol10", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.TextQualifier = "\'";
            dfs.GeneralSettings.HeaderRowsToSkip = 10;
            dfs.GeneralSettings.HeaderRowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");
            dfs.ColumnSettings.ColumnDelimiter = DelimiterStringConverter.ToReadableDelim("|");
            dfs.ColumnSettings.RowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");
            dfs.GeneralSettings.CodePage = PresenterUtils.ConvertCodepageToString(65001);

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_UTF8_10Col_TQ_Headers_CustomDel.txt", 10, "\n"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_Unicode1ColNoTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_Unicode_1Col_NoTQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.IsUnicode = true;

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_Unicode_1Col_NoTQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_Unicode1ColTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_Unicode_1Col_TQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.IsUnicode = true;
            dfs.GeneralSettings.TextQualifier = "\"";

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_Unicode_1Col_TQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_Unicode1ColTQHeadersCustomDelInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_Unicode_1Col_TQ_Headers_CustomDel.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.IsUnicode = true;
            dfs.GeneralSettings.TextQualifier = "\'";
            dfs.GeneralSettings.HeaderRowsToSkip = 10;
            dfs.GeneralSettings.HeaderRowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");
            dfs.ColumnSettings.ColumnDelimiter = DelimiterStringConverter.ToReadableDelim("|");
            dfs.ColumnSettings.RowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_Unicode_1Col_TQ_Headers_CustomDel.txt", 10, "\n"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_Unicode10ColNoTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_Unicode_10Col_NoTQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol2", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol3", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol4", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol5", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol6", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol7", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol8", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol9", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol10", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.IsUnicode = true;

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_Unicode_10Col_NoTQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_Unicode10ColTQInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_Unicode_10Col_TQ.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol2", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol3", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol4", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol5", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol6", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol7", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol8", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol9", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol10", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.IsUnicode = true;
            dfs.GeneralSettings.TextQualifier = "\"";

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_Unicode_10Col_TQ.txt"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        [TestMethod]
        public void StdOut_Unicode10ColTQHeadersCustomDelInput_FilesMatch()
        {
            DFSIntegrationTestPackage dfs = new DFSIntegrationTestPackage("Input_Std_Unicode_10Col_TQ_Headers_CustomDel.txt", _testContextInstance);
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol1", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol2", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol3", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol4", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol5", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol6", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol7", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol8", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol9", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.AdvanceSettings.Columns.Add(dfs.CreateCol("TestCol10", 0, 0, RunWrapper.DataType.DT_WSTR, 255, 0));
            dfs.GeneralSettings.IsUnicode = true;
            dfs.GeneralSettings.TextQualifier = "\'";
            dfs.GeneralSettings.HeaderRowsToSkip = 10;
            dfs.GeneralSettings.HeaderRowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");
            dfs.ColumnSettings.ColumnDelimiter = DelimiterStringConverter.ToReadableDelim("|");
            dfs.ColumnSettings.RowDelimiter = DelimiterStringConverter.ToReadableDelim("\n");

            dfs.Execute();
            Assert.IsTrue(dfs.IsStandardOutputFileSameAs("Input_Std_Unicode_10Col_TQ_Headers_CustomDel.txt", 10, "\n"));
            Assert.IsTrue(dfs.IsLogOutputFileSameAs("Empty.txt"));
            Assert.IsTrue(dfs.IsErrorOutputFileSameAs("Empty.txt"));
        }

        //[TestMethod]
        public void CreateTestData()
        {
            RunWrapper.DataType[] columns = new[] 
                {
                    RunWrapper.DataType.DT_STR,
                    RunWrapper.DataType.DT_UI1,
                    RunWrapper.DataType.DT_I4,
                    RunWrapper.DataType.DT_NUMERIC,
                    RunWrapper.DataType.DT_DBTIMESTAMP
                    //RunWrapper.DataType.DT_STR,
                    //RunWrapper.DataType.DT_STR,
                    //RunWrapper.DataType.DT_STR,
                    //RunWrapper.DataType.DT_STR,
                    //RunWrapper.DataType.DT_STR
                };

            TestDataGenerator.CreateFile(@"C:\SourceCode\DBGDelimitedFileSource\DBG Delimited File Source\v2005\IntegrationTestDelimitedFileSource\TestData\Err_ASCII_5Col_TQ_UK.txt",
                Encoding.ASCII, 30, columns, 0, "\"", ",", "\r\n", true, 50, 2057, true);
        }
    }
}
